package edu.calpoly.android.lab1adiel;

//import android.R;
import edu.calpoly.android.lab1adiel.R;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

public class ButtonListener extends Activity implements OnClickListener {
	
	android.widget.EditText _textField;
	private static final int CAMERA_PIC_REQUEST = 1337; 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.name_getter);
		this._textField = (EditText) this.findViewById(R.id.enterNameTextField);
		android.widget.Button tButton = (Button) this.findViewById(R.id.cameraButton);
		tButton.setOnClickListener(this);
	}
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
	    if (requestCode == CAMERA_PIC_REQUEST) {  
	    	Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
	    	ImageView image = (ImageView) findViewById(R.id.photoResultView);  
	    	image.setImageBitmap(thumbnail);  
	    }  
	}  
	
//	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		String tInputText = this._textField.getText().toString();
		//android.provider.MediaStore.ACTION_IMAGE_CAPTURE
		Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
		startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST); 
		//android.content.Intent tIntentClass = new Intent(this, HelloWorld.class);
		//tIntentClass.putExtra("userName", tInputText);
		//this.startActivity(tIntentClass);
		}

}
